/*
*  NSRTMParamsCriteria.m
*  RTMApiTest
*
*  Created by kkillian on 17/11/09.
*  Copyright 2009 shufflecodebox. All rights reserved.
*	This program is free software; you can redistribute it and/or modify
*	it under the terms of the GNU General Public License as published by
*	the Free Software Foundation; either version 2 of the License, or
*	(at your option) any later version.
*
*	This program is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*	GNU General Public License for more details.
*
*	You should have received a copy of the GNU General Public License
*	along with this program; if not, write to the Free Software
*	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#import "NSRTMParamsCriteria.h"

#define RTMCriteriaListName @"list"
#define RTMCriteriaTaskName @"name"
#define RTMCriteriaNoteContains @"noteContains"
#define RTMCriteriaHasNotes @"hasNotes"
#define RTMCriteriaPriority @"priority"
#define RTMCriteriaTimeEstimate @"timeEstimate"
#define RTMCriteriaPostponed @"postponed"
#define RTMCriteriaStatus @"status"

#define RTM_TRUE @"true"
#define RTM_FALSE @"false"

@implementation NSRTMParamsCriteria

+(NSRTMParamsCriteria *)criteriaWithListName:(NSString *)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaListName] retain];
	[criteria setCriteriaValue:value];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithTaskName:(NSString *)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaTaskName] retain];
	[criteria setCriteriaValue:value];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithNote:(NSString *)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaNoteContains] retain];
	[criteria setCriteriaValue:value];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithNoted:(BOOL)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaHasNotes] retain];
	if(value) {
		[criteria setCriteriaValue:RTM_TRUE];
	} else {
		[criteria setCriteriaValue:RTM_FALSE];
	}	
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithPriority:(NSInteger *)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaPriority] retain];
	[criteria setCriteriaValue:[NSString stringWithFormat:@"%d", value]];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithEstimeteTime:(NSString *)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaTimeEstimate] retain];
	[criteria setCriteriaValue:value];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithPosponedNum:(NSInteger*)value option:(NSRTMPosponedFilter)filter {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaPostponed] retain];
	[criteria setCriteriaValue:[NSString stringWithFormat:@"%d", value]];
	return criteria;
}

+(NSRTMParamsCriteria *)criteriaWithStatus:(NSRTMStatusOptions)value {
	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaStatus] retain];
	if(value == NSRTMTaskStatusCompleted) {
		[criteria setCriteriaValue:@"completed"];
	} else {
		[criteria setCriteriaValue:@"incomplete"];
	}	
	return criteria;
}

@end
